<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html ng-app="app" id="ng-app">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<%@include file="/include/style.jsp"%>
<%@include file="/include/script.jsp"%>
<script type="text/javascript" src="/js/page/enum.js?v=<%=Constants.VERSION %>"></script>
<script type="text/javascript" src="/js/page/order.js?v=<%=Constants.VERSION %>"></script>
<script type="text/javascript">
var QUERY_COOKIE = '${requestScope.cookie}';
</script>
</head>
<body ng-controller="OrderCtrl">
	<div class="toolbar">
		<div class="left-area">
			<form ng-submit="search()">
				<input type="text" ng-model="formCondition.keyword" placeholder="订单编号或客户ID" class="search-box">
			</form>
		</div>
  		<div class="right-area">
  			<permission:valid permission="<%=Constants.ORDER_CUD%>">
				<button class="btn btn-success" type="button" ng-click="createOrder()"><i class="fa fa-plus"></i> 新增 </button>
			</permission:valid>
  		</div>
	</div>
	
	<div ng-if="page.rows.length>0">
		<table class="data-table" style="table-layout:fixed;">
			<thead>
				<tr>
					<th width="4%">序号</th>
					<th width="15%" style="text-align: left;">订单编号</th>
					<th width="10%" style="text-align: left;" ng-click="sortBy('sale_date')" class="sort">售出日期&nbsp;<i ng-class="direction('sale_date')">&nbsp;</i></th>
					<th width="10%" style="text-align: left;" ng-click="sortBy('customer_id')" class="sort">客户ID&nbsp;<i ng-class="direction('customer_id')">&nbsp;</i></th>
					<th width="20%" style="text-align: left;">客户邮箱</th>
					<th width="15%" style="text-align: left;">客户电话</th>
					<th width="8%">状态</th>
					<permission:valid permission="<%=Constants.ORDER_CUD%>">
					<th width="18%">操作</th>
					</permission:valid>
				</tr>
			</thead>
		   <tbody>
			  <tr ng-repeat="order in page.rows">
				  <td align="center">
				  	<span ng-bind="($index)+1"></span>
				  </td>
				  <td ng-bind="order.id"></td>
				  <td ng-bind="order.saleDate | date: 'yyyy/MM/dd'"></td>
				  <td ng-bind="order.customerId"></td>
				  <td ng-bind="order.customerEmail"></td>
				  <td ng-bind="order.customerPhone"></td>
				  <td align="center" ng-bind="order.status"></td>
				  <permission:valid permission="<%=Constants.ORDER_CUD%>">
				  <td align="center">
					<span class="btn btn-link" ng-click="editOrder(order)" ng-if="order.status!='Delivered'"><i class="fa fa-pencil"></i> 修改</span>
					<span class="btn btn-link" ng-click="deleteOrder(order)" ng-if="order.status!='Delivered'"><i class="fa fa-trash"></i> 删除</span>
					<span class="btn btn-link" ng-click="deliverOrder(order)" ng-if="order.status!='Delivered'"><i class="fa fa-truck"></i> 发货</span>
					<span class="btn btn-link" ng-click="sendEmail(order)" ng-if="order.status=='Delivered'"><i class="fa fa-envelope-square"></i> 重发邮件</span>
				  </td>
				  </permission:valid>
			  </tr>
		   </tbody>
		</table>
		
		<%@include file="/include/pageBar.jsp" %>
	</div>
	
	<div class="alert alert-success" style="clear: both;" ng-if="page.rows.length==0">
		暂无数据！
	</div>
</body>
</html>